from selenium import webdriver


# 登录功能的测试代码
class GetFact():
    # 初始化属性
    driver = None

    @classmethod
    def get_driver(cls):
        if cls.driver is None:
            cls.driver = webdriver.Chrome()
        cls.driver.maximize_window()
        cls.driver.implicitly_wait(10)
        # 调用登录方法
        GetFact().login()
        return cls.driver

    @classmethod
    def login(cls):
        # 打开网页
        cls.driver.get('http://shop-xo.hctestedu.com/admin.php')
        # 定位用户名
        cls.driver.find_element_by_name('accounts').send_keys('huace_tester')
        # 定位密码
        cls.driver.find_element_by_name('pwd').send_keys('123456')
        # 定位登录按钮
        cls.driver.find_element_by_css_selector('button[type="submit"]').click()
